Not working yet but here's a basic outline