Fixing spacing issues and try-catch logic error