updated version to store all data on serverside in mongodb