fix bug in sync return, trim before returning output