intial version. works for simple examples.