edited lines 78-121 for our code