Qisheng, 43, had been working for Huaxia Bank in Beijing when he realized in 2016 that cash withdrawals made around midnight were not recorded, the news outlet reported.

So in November of that year, Qisheng added scripts to the bank’s software, allowing him to test the loophole without setting off any alarms.

For more than a year after that, Qisheng made cash withdrawals of between $740 and $3,000 from a phony account used to test the bank’s systems — racking up until more than $1 million.

Qisheng put the newfound lump sum into his own bank account and even invested some of it in the stock market, according to the report.

Despite what Qisheng did with the cash, the bank accepted Qisheng’s explanation that he was simply trying to test the bank’s internal security.

According to court documents, the bank did admit that Qisheng should have reported his doings and that his actions were a violation of the banks protocol.

Authorities, however, were not as kind to Qisheng.

In December, Qisheng was jailed for theft, according to the South China Morning Post.

Huaxia Bank had even filed a request that police drop the case after Qisheng returned the money.

“Qin Qisheng said that the matter was complicated and involved lots of work … he believed the bank would not pay attention even if he reported it,” a bank representative said at Qisheng’s trial in December, according to the news outlet.

“We think this reason for not reporting is legitimate,” the representative said.

The Chaoyang district court ultimately found Qisheng guilty and said that even though he had returned the money to the bank before his arrest, it wasn’t enough to save him, according to the report.

“On the one hand, [the bank] said that the accused’s behavior was in violation of the rules. On the other hand he said that he could conduct relevant tests. This is self-contradictory,” the judge said, the news outlet reported.

Along with the prison sentence, Quisheng was fined $1,600.

Quisheng filed an appeal after the trial, arguing that he did not deserve such a harsh punishment.