cleaned up code and added timestamp to POST request