Converted to class and added extend and union methods