fixed code smells

Removed access to non-existent array items and warning suppression as it is considered not best practice.