added response construction safeguards against nil data