worked on error handling