refactored to include embedding lookups in model
fixed off by one error