removed infinite loop
fixed copy