decoding.rb refactorized