Refactor

Used trim instead preg_replace, and set empty string as default