removed unneeded check.
refactored query and relation.