Fixed the bug, completes all tests correctly