added camera index checking