Improved function logic to one statement and remove unnecessary functions

Signed-off-by: Chanaka Indrajith <pe.chanaka.ck@gmail.com>