adding patch from stuartmemo and cwilso