tests are now passing and a litle refactoring was made