refactoring stuff into parent optim pkg