changed hasattr to has_key to avoid infinite recursion on CentOS