Updated to be more 'pythonic' code.