Moved mongoose code to seperate file