refactor few things in string calculator