seems to have an infinite loop in it