implementation of algebra classes