first working prototype of api refactored