In May 1803, after attending further courses of lectures at the University of Edinburgh, and acting as assistant to the professor of mathematics at St Andrews, he was ordained as minister of Kilmany, about 9 miles from the university town, where he continued to lecture.