refactoring my sql calls on home page