Added doc tag and made the code more defensive