Fixed the select queries