undefined offset error solved