finished most parts of merging previous work:fix