refactored to use streams instead of str to num conversions