move duplicate code into function library

On branch master
Changes to be committed:

	modified:   includes/km.lib
	modified:   setup1.sh