1. A method of controlling an aftertreatment system having a SCR catalyst and communicating with an engine ECM, comprising the steps of: receiving a plurality of system values corresponding to NH 3 and NO x emissions of the aftertreatment system; determining an optimal urea dosing target value based on the system values and one of a target NH 3 storage value and an estimated NH 3 storage value; and determining an optimal engine NO x output target value based on the system values and a measured NO x conversion efficiency value.