fix trim on undefined issue
small refactor