don't dump an empty hash in the success case
reorder code for a bit of efficiency