onBeforeShow method