move key formatting into private method