Tope's ruby code