handles dependencies resolving, needs refactor!