fixing bugs and formatting print.