Fixed some illogical logic