Modified set method to give a more robust behavior