did a bunch of refractoring ->still need to write more tests