Fixed undefined index issue