refactored logic, less boilerplate