moved incrementer after error check