made sure everything is cleanup on errors