implement user define function