fixed script restrict #43
cleaned up code