finished the basic functionality