Refactor funcs