Reordered the plan for the application logic in the comments.