added validation of prompt string to ensure no null objects are created