finished most of the basic functionality