changed max key method back to 2