changed removechar to return result