Improve error handling
Change string formatting
These changes address comments in code review