Extracted code to separate files