now functional but very buggy and slow