Why doesnt this condition work as i expect?