refactoring and improvement to civomega answer code