Refactored to split main file into several