Code reorg for better output