make java solution better (lol wut)