refactored even more