adding check to Object.keys call to correct thrown error