Working verison tested for some functions. need to test more.