Made a major code change, hope it works