error-handling implemented

error-handling implemented