mark: removing unused code
mark: simplifying algorithm for ruby version too