fix permit bugs