fixing a couple logic bugs I found