refactored methods touse auto-code generation; code is stable, less bug prone, and more maintainable now.