added null and empty check