Refactor based on inheritance