Updated splice function