made the code nice and python like