Fixed logic. Should theoretically work. Probably doesn't