refactoring
error handling