wrote restriction function but not sure if its working.