some ideas for refactoring