seems to work for basic test cases