updated code after lab 5