Fixed some condition checking