Seems to work for simple cases