finished the basic implementation