Fix undefined variables throwing exception with length filter