Fixed some logical programming