updated with Jeffreyg changes