Seems to work, ready for some more testing