improved class logic