starting functions for query