fix protect + reorder functions