first try for main program and optim :)