a buggy solution to p1009