improvements to grep script