Removed some code duplication via inheritance