an attempt at a more object-oriented approach