update for optional parameters and clean up.