Refactor
two functions