switched to Object.keys and while loops (from for..in)