fixed output and broken loops