Slight refactor to functions.