Refactoring and a little error handling