adding empty check
adding stackoverflow