improvements; move string replace to regex