working version - after separate funcs