wait function now waits after everything's done setting up