Made SQL statement customizable