Something's wrong with my logic. Added some debugging output.