moved event logic to update