Final version. Fixed output formatting