Refactor based on S Purcell's approach