bugfix -- remove while, change to go-loop