some logical errors in class. :-(