regex amended to reduce code