Nick Becker's fixed functional.py