helper function for cleaning input