compiles but buggy