refactoring error handling, output to console