have a look at "on_level" at the Manual.