re-wrote stringoptimizer using scopes