Slight refactor to aid performance