Minor changes, moded code to function
Signed-off-by: Mohamed Thalib <hmthalib@gmail.com>