added conditional event handlers