Seperated Convert logic from main module and added some commentation