added comments and fixed stringmid call in the copy function