cleaning up log switch logic