Updated with basic comments for readability