added write to space and mongo db functions