Code optimize on retrieving records from mongo