Refactor based on Dan's feedback