refacto with an event based mechanism