more error handling, more comments