Fixed errors for empty substring