minor changes to move validation up