fix Undefined index: error
fix phpcs violations