refactor on Sam's feedback