added the changes mentioned by David