Address review comments, remove duplicate code