NEW YORK (AP) — Michael Cohen, who as President Donald Trump’s personal lawyer and fixer once vowed he would “take a bullet” for his boss, was sentenced Wednesday to three years in prison for an array of crimes that included arranging the payment of hush money to two women that he says was done at the direction of Trump.

The sentence was in line with what federal prosecutors asked for. Sentencing guidelines called for around four to five years behind bars, and prosecutors asked in court papers that Cohen be given only a slight break. He is ordered to surrender March 6.

Cohen, standing alone at the defense table, shook his head slightly and closed his eyes briefly as the sentence was announced by the judge.

U.S. District Judge William H. Pauley III said Cohen deserved modest credit for his decision over the summer to admit guilt and cooperate in a federal investigation of efforts by Russians to influence the presidential election, but his assistance “does not wipe the slate clean.”

“Somewhere along the way Mr. Cohen appears to have lost his moral compass,” the judge said. “As a lawyer, Mr. Cohen should have known better.”

Cohen told the judge just before he was sentenced that loyalty to Trump led him astray.