This function is kinda big. Can we pull it out into a `lib/` module to keep `ViewfinderController` clean?