dirty version
added the idle mode