Converted trigger to function for user point update