first working implementaion, some cli fixes still needed