fixed bugin error handing