added grep function and improved formatting