Fix stackoverflow error