last edits to intermediate_functions.py