changed sleep to call switch inside function