improved setup routine