moved config section to down script start and put the find home routine into a function