fixed a stackoverflow problem