Fixed the selects with where clause