Functional solver now, seems to work completely