improve removal of invalid chars