refactored without breaking anything