Updated solution for step 4