Check index validity before querrying data from model

Change-Id: Ifa48f526e9da38116ecfe5572cfad5cbb48208b8
Reviewed-by: Niels Weber <niels.weber@digia.com>