Wip/func optimizing