implement functions and events