Fixed undefined index errors