Abstraction of codes

moved codes outside the codebase for easier updating