Refactored is_constant