finished implementation. no debugging yet