Started implementing optimization algorithm