add working prototype
refine and cleanup