Updated solution for step 2