indent and fix logic for printing output