fixes a stackoverflow error fix #42