refactoring code

Change-Id: I0e67e489fcae0c5e48c38b96651fbe8c99d127ac
Signed-off-by: Marcelo Portilho <marceloport@gmail.com>
Refactoring for better code and performance

Change-Id: Ic287c69ee25cbbefa3dba4a3cafff4f004f5413e
Signed-off-by: Marcelo Portilho <marceloport@gmail.com>