missed a testing scenario and a bug in the code, plus formatting