duplicated sql query removed