first tested; some errors found&fixed