improved functionality for strip whitespace