fixed error in duplicate function