Refactor to func style