Fixed substring out of bounds in firebasesession