proj3 main and subfunctions start