refactor beautifully