polishing up error handling