incorporate michaeljb's changes