refactored, so beautiful