Cleaning up error handling
Fix formatting