added event handler and map updating function