function optimization

Change-Id: I9017b0f0afc6982b9775c1a4fcfbb4ed229bf376
Signed-off-by: Eyal Salomon <esalomon@mellanox.com>