updated code

this code was overall pretty solid. the only things i would really recommend are reading up on the pep8 style guide and getting a linter for your code. i'd also watch out for scoping and naming things that won't conflict.