changed solution and added tests