atomic block to avoid interrupt interruptions