Minor fix, changed where apm is called