chagned check_key function to look for env var if present