added the provided code from lab 3