refactored the code

Fixed in https://github.com/wso2-dev/carbon-business-process/pull/13/files