edited based on Dan's comments