Fixed double "WHERE" appending issue