Extracted some parts for easier usability and readability.