convert data to string before invoking trim()