buggy, but works somewhat