Added onBeforeShow event