Working version (without editing) with functions like in example