improve setup function