Refactored to use one method instead of several methods