stackoverflow exception fixed