Start of more generic and correct way generating queries