Using changes suggested by jtratner