refactored files and functions