fixed a few bugs but still need to tinker