Fixed undefined index error