almost done ( just tests ) and refactore code if neeeded