Main function update