Improve some where queries