Reimplimented Torins code with changes

So, here you go Marcos