made code more pythonesque