Made some progress with some functions. Yet to test