some comments added, removed unneccesary function  'copyit'