Jason's code refactor