logic to bind events