fixed a bug, wrote a test