begin event coding