fixing stackoverflow

@adamshone Simple enough change, but could you please review?