remove duplicate code and take 423 into concern