refactored without error