now fully working program, just a little slow