added Jeffrey's code