refine mongoose sample code