Updated positionByFrameGen.rb with a refactored version