moved error handling and made sure to notify callback when something fails