added some code. not tested and doesn't compile