fix None.get error in the code