updated to work with the latest code