Add debug format
Add array check for each result and implode only if it is an array