old limit checking code