Refactored code for new package structure