Fix logic issue