more refactoring, started adding priority