fixing the bug 'cannot read length of undefined' in calendar