fixes logic bug