Add objective function

change drawing logic