basic version working with some bugs