functions finished, debug needed