refactor function
refactor function