Format response better and handle errors