fix in date sorting in cases where there's only one item
attempt at fixing UTF8 encoding in JSON output
added use utf8
upgrading utf8 instead of decoding it at the end