Adding comments and error handling
Adding comments and error handling