improve regex handling