added sleep and modified c_swi_handler