fully working, found a bug in printing