Implemented smarter ingredient association; fixed index out of bounds issue