adding checks for array-element existence; so as to avoid lots of warnings