added some dir check and decided to use functions next