Continuation code refactored for re-use