Refactor code to use stub