a lot of tweaks code works

should be next to last commit