Changed for in loops to Object.keys().forEach() loops