Replace deprecated has_key method

This patch replaces the deprecated 'has_key' method for dictionaries and uses the 'in' keyword instead.