changed 'has_key' references to 'in' for python3 compatibility