fixed maxArray + main working