modified with mike's stuff