added separate query and arrays for cid and user account id