refactor recursive function
Separate modules folder