improve setup logic