REctifying query to be syntectically correct