added more robust type checking for constants