fixed classcast problem and index in tuple