Fixing issue where index is undefined in count method of vbox