this compiles and runs, no idea if it is correct though