methods refactored so code is cleaner