debugging and handlling the errors