avoiding unnecessary mongoid calls

Refer the pastebin for the reduction in the number of mongoid queries.

http://pastebin.test.redhat.com/129455