Added null case handling