copy code from lab4