An excellent solution and, overall, a very well-coded contract @ibn5x 
Apologies for the delay in giving you some feedback.
You have added all of the additional lines of code needed to solve the problem with the withdraw function, and they are in the correct order to reduce security risk:
- check inputs (require statements)
- effects (update the contract state)
- external interactions
Itâs important to modify the contract state for the reduction in the balanceâŚ
balance[msg.sender] -= amount;
before actually transferring the funds out of the contract to the external wallet addressâŚ
userAddress.transfer(amount);
⌠just in case there is an attack after the transfer, but before the state is modified to reflect this operation. Youâll learn about the type of attack this prevents, and how it does it, in later courses. We wouldnât expect you to know this at this early stage, though, so Iâm just telling you for extra information, in case you havenât already seen this explanation in some of the other posts in this discussion topic. But itâs great that youâre already getting into good habits in terms of smart contract security 
Your transfer event and corresponding emit statement are both well coded, and the emit statement will log relevant information when the function has executed successfully. I would just add, though, that in general, emit statements are probably better placed after assert statements, rather than before.
Your function to get the total contract balance (in additional to individual user balances) is also very good. However, you do have a redundant state variable contractValue
which isnât used, and so should be removed. I guess you must have forgotten to remove it when you realised you could just useâ account(this).balance
Let me know if you have any questions 