updated the optimization code

Signed-off-by: Amit Shah <amit.shah@tum.de>