fixed bug in multitasking code