removed unnecessary trimming, added testcase for empty method