fix undefined index
phpdoc & formatting improvements