Checking length of models to prevent js error