refactored most of the methods