another version using more inheritance