updated documentation
re-implement using virtual functions for faster compilation