Added switch and tests, removed unnecessary imports from ifelse, and optimized function queue in promisify