fix range check in getFields - fixes issue 687