reduced sql queries...pass value in functions