IF ts.song IS NOT NULL THEN
ret.max_score := ret.max_score + ( SELECT max_score FROM get_max_score_for_songs($1, $4) WHERE song=ts.song );
ELSE
IF ts.song IS NOT NULL THEN
ret.max_score := ret.max_score + ( SELECT max_score FROM get_max_score_for_songs($1, $4) WHERE song=ts.song );
ELSE