add trim in cleanup function