initially workable version, even still buggy...