merged Greg Caldwell version