Remade logic for boolean funcution.