fixed bug wih ~ operator