cleaned up code and refactored to only open scan view after popup button is pressed