refactor potter ruby