store into mongodb
remove last entry before send to server
pass correct json string to the server