bug fixed and used sed instead of grep