moved idle to separate function