refactored!