Seems to work, need to add tests