added sql helper functions