initial working implementation
refactor