refactored business logic, cleaner now