Refactor as to make generic.