handle ~ correctly