Better dictionary handling. Using max function.