modified the function to only show printable characters