under refactoring function
refactor function