fixing things up from mpdehaan's suggestions