added function entering/leaving