Purpose: Major Functions Extracted

Made the code more clear.