fixed .length error so that md without images can be processed too