add ath, refactoring code.