apply length restriction at the right time