Seperated Convert logic from main module and added some commentation

Still need to add more comments to functions and improve decoupling.