Small fix to solve 'Cannot read property length of undefined'