fixing table row order by issue remvoing unwanted clauses