refactored with resources