Bug fix to check values