Fixed order of operations bug in code.