changed some where statements to couchrest style