Cleaned up the extends function