a buggy solution to p1007