Changed formatting slightly
Rewrote rupgrade by using functions