incorporated David's latest changes