Sketched out algorithm

Some parts need to be explained more