refactoring
external function call improvements