code with human/bot switch complete