improved dir setup and created a function for it