REFACTOR: main functions & members