REplace code with function call