added event listeners, now handles POST requests