first semi-functional version