Fixed some broken logic