Fix undefined index and deprecated split()