Added some simple error control to the eventListener.