Final version working code, please make sure all of your tests are consistent with this - harsha