You replaced the expression by a instead of substituting a into the expression for x.