refactoring to be more scalable