final function definitions for step 1