handling events + improve