added check for Result, getState function main-model, REF #591

when there was no result it was trowing an array_key_exists error.