kinda got it working. still buggy in some situations