refactored piece.rb