improve code; main scope access; remove event