added an isset control to avoid non existent array offset check