Primary Controller Code