improved and filled out code added tests