first attempt, yet very buggy