Still telling me that formattedmsg isnt defined. Now defining it inside the if statement