Modified the code a bit to the Python style guide