fixing regex pattern and back logging of tail