introduced dependency managment
refactored for readability