update cli tool to trim properly, catch errors