fixed issues with splice function