some modifications to Mike's stuff