refactored/cleanup, better grep configuration