BS2 Main code