Fix bug in mongo query