added recoloring to Meril's code