edits to Mike's code