Refactor resources selecting.