fixed (ahem) silly logic bugs