replaced pop with splice