refactored using .keys method