Fix SQL, add a comment and remove unnecessary if