completed code for stubbed functions and added comments