new version with copy bugs fixed