add comment and error handling