Added helper method to remove stray commas and "null" string from output