improved regex, cleandb function