attempt to pythonify the code a little more