refactored the methods