Code refactor for function calls