refactored and updated function calls