Adding event functionality