improved parsing and printing