adding instructor's code, still unfinished