Changing to mongodb queries & Building getDirectories function