Added swtich and logging