refac and get dependencies in order